const express = require('express')
const collection = express.Router()
const axios = require('axios')
collection.get('/collection/album', (req, res) => {
        //获取用户收藏专辑
        let { pageNo, pageSize, userId } = req.query
        axios({
            method: 'get',
            url: '/user/getAlbumCollect',
            params: {
                pageNo: pageNo,
                pageSize: pageSize,
                userId: userId
            },
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
            }
        }).then(data => {
         console.log(session);
            console.log(data.data);
            res.status(200).json({
                data: data.data
            })
        }).catch(err => {
            console.log(err);
            res.status(200).json({
                err: err
            })
        })
    })
    //获取用户收藏文章
collection.get('/collection/article', (req, res) => {

    let { pageNo, pageSize, userId } = req.query
    axios({
        method: 'get',
        url: '/user/getForumCollect',
        params: {
            pageNo: pageNo,
            pageSize: pageSize,
            userId: userId
        },
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
        }
    }).then(data => {
        console.log(data.data);
        res.status(200).json({
            data: data.data
        })
    }).catch(err => {
        console.log(err);
        res.status(200).json({
            err: err
        })
    })
})

collection.get('/personCenter/picture', (req, res) => {

    let { pageNo, pageSize, userId } = req.query
    axios({
        method: 'get',
        url: '/user/getMyForums',
        params: {
            pageNo: pageNo,
            pageSize: pageSize,
            userId: (userId == '' ? req.session.userMessage.id : userId)
        },
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
        }
    }).then(data => {
        console.log(data.data);
        res.status(200).json({
            data: data.data
        })
    }).catch(err => {
        console.log(err);
        res.status(200).json({
            err: err
        })
    })
})





module.exports = collection